home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_400 / setcpu / control.i < prev    next >
Text File  |  1992-05-06  |  5KB  |  195 lines

  1. ;======================================================================
  2. ;
  3. ;    SetCPU V1.60
  4. ;    by Dave Haynie, April 13, 1990
  5. ;    Released to the Public Domain
  6. ;
  7. ;    CONTROL.A MODULE
  8. ;
  9. ;    This module contains functions that access various control
  10. ;    registers in the 32 bit CPUs and MMUs.
  11. ;
  12. ;======================================================================
  13.  
  14.     include "setcpu.i"
  15.  
  16.     cseg
  17.  
  18. ;**********************************************************************
  19. ;
  20. ;    These functions work with the CPU control registers.
  21. ;
  22. **********************************************************************
  23.  
  24.     xdef    _SetCACR    ; Set CACR register
  25.     xdef    _GetCACR    ; Get CACR register
  26.     xdef    _GetVBR        ; Get the Vector Base Register
  27.  
  28. ;======================================================================
  29. ;
  30. ;    This function sets the value of the 68020/68030 CACR register.  
  31. ;    It assumes a 68020 or 68030 based system.
  32. ;
  33. ;    void SetCACR(cacr)
  34. ;    ULONG cacr;
  35. ;
  36. ;======================================================================
  37.  
  38. _SetCACR:
  39.     move.l    4(sp),d0        ; New CACR is on stack
  40.      move.l    4,a6            ; Get ExecBase
  41.     move.l    a5,-(sp)        ; Save this register
  42.     lea.l    1$,a5            ; Get the start of the supervisor code
  43.     CALLSYS    Supervisor
  44.     move.l    (sp)+,a5        ; Give it back
  45.     rts
  46. 1$
  47.     MOVEC_    d0,cacr            ; Set the CACR
  48.     rte
  49.  
  50. ;======================================================================
  51. ;
  52. ;    This function returns the 68020/68030 CACR register.  It assumes
  53. ;    a 68020 or better system.
  54. ;
  55. ;    ULONG GetCACR()
  56. ;
  57. ;======================================================================
  58.  
  59. _GetCACR:
  60.     move.l    4,a6            ; Get ExecBase
  61.     move.l    a5,-(sp)        ; Save this register
  62.     lea.l    1$,a5            ; Get the start of the supervisor code
  63.     CALLSYS    Supervisor
  64.     move.l    (sp)+,a5        ; Give back register
  65.     rts
  66. 1$
  67.     MOVEC_    cacr,d0            ; Make CACR the return value
  68.     rte
  69.  
  70. ;======================================================================
  71. ;
  72. ;    This function returns the value of the Vector Base Register;
  73. ;    all exceptions are referenced from this.  This function assumes
  74. ;    we're on a CPU with a VBR (eg, no 68000's need apply).
  75. ;
  76. ;    ULONG *GetVBR()
  77. ;
  78. ;======================================================================
  79.  
  80. _GetVBR:
  81.     move.l    4,a6            ; Get ExecBase
  82.     move.l    a5,-(sp)        ; Save this register
  83.     lea.l    1$,a5            ; Get the start of the supervisor code
  84.     CALLSYS    Supervisor
  85.     move.l    (sp)+,a5        ; Give back register
  86.     rts
  87. 1$
  88.     MOVEC_    vbr,d0            ; Make CACR the return value
  89.     rte
  90.  
  91. ;**********************************************************************
  92. ;
  93. ;    These functions access MMU registers
  94. ;
  95. ;**********************************************************************
  96.  
  97.     xdef    _GetCRP        ; Gets MMU CRP register
  98.     xdef    _SetCRP        ; Sets MMU CRP register
  99.     xdef    _GetTC        ; Gets MMU TC register
  100.     xdef    _SetTC        ; Gets MMU TC register
  101.  
  102. ;======================================================================
  103. ;
  104. ;    This function returns the MMU CRP register.  It assumes a 68020 
  105. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  106. ;    you call this, or you wind up in The Guru Zone).  Note that the
  107. ;    CRP register is two longwords long.
  108. ;
  109. ;    void GetCRP(ULONG *)
  110. ;
  111. ;======================================================================
  112.  
  113. _GetCRP:
  114.     move.l    4(sp),a0        ; Pointer to the CRP storage area
  115.     move.l    4,a6            ; Get ExecBase
  116.     move.l    a5,-(sp)
  117.     lea.l    2$,a5            ; Get the start of the supervisor code
  118.     CALLSYS    Supervisor
  119.     move.l    (sp)+,a5
  120.     rts
  121. 2$
  122.     PMOVE_    crp,(a0)        ; Just get the CRP register
  123.     rte
  124.  
  125. ;======================================================================
  126. ;
  127. ;    This function sets the MMU CRP register.  It assumes a 68020 
  128. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  129. ;    you call this, or you wind up in The Guru Zone).  Note that the
  130. ;    CRP register is two longwords long.
  131. ;
  132. ;    void SetCRP(ULONG *)
  133. ;
  134. ;======================================================================
  135.  
  136. _SetCRP:
  137.     move.l    4(sp),a0        ; Pointer to the CRP storage area
  138.     move.l    4,a6            ; Get ExecBase
  139.     move.l    a5,-(sp)
  140.     lea.l    1$,a5            ; Get the start of the supervisor code
  141.     CALLSYS    Supervisor
  142.     movem.l    (sp)+,a5        ; Give back registers
  143.     rts
  144. 1$
  145.     PMOVE_    (a0),crp        ; Just load the CRP register
  146.     rte
  147.  
  148. ;======================================================================
  149. ;
  150. ;    This function returns the MMU TC register.  It assumes a 68020 
  151. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  152. ;    you call this, or you wind up in The Guru Zone).  
  153. ;
  154. ;    ULONG GetTC()
  155. ;
  156. ;======================================================================
  157.  
  158. _GetTC:
  159.     move.l    4,a6            ; Get ExecBase
  160.     move.l    a5,-(sp)
  161.     subq.l    #4,sp            ; Make a place to dump TC
  162.     move.l    sp,a0
  163.     lea.l    1$,a5            ; Get the start of the supervisor code
  164.     CALLSYS    Supervisor
  165.     move.l    (sp),d0            ; Here's the result
  166.     addq.l    #4,sp
  167.     move.l    (sp)+,a5
  168.     rts
  169. 1$
  170.     PMOVE_    tc,(a0)            ; Just get the TC register
  171.     rte
  172.  
  173. ;======================================================================
  174. ;
  175. ;    This function sets the MMU TC register.  It assumes a 68020 
  176. ;    system with MMU, or a 68030 based system (eg, test for MMU before
  177. ;    you call this, or you wind up in The Guru Zone).  
  178. ;
  179. ;    void SetTC(ULONG)
  180. ;
  181. ;======================================================================
  182.  
  183. _SetTC:
  184.     lea.l    4(sp),a0        ; Get address of our new TC value
  185.     move.l    4,a6            ; Get ExecBase
  186.     move.l    a5,-(sp)
  187.     lea.l    1$,a5            ; Get the start of the supervisor code
  188.      CALLSYS    Supervisor
  189.     move.l    (sp)+,a5
  190.     rts
  191. 1$
  192.     PMOVE_    (a0),tc            ; Just set the TC register
  193.     rte
  194.  
  195.